// Tags:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>

const int N = 1e4 + 5;
int n, len, p[N], shf;
char opt[N];

void solve(int x, int len) {
  if (len == 1) return;
  int tmp = len / 3;
  for (int i = x + tmp; i < x + (tmp << 1); ++i) std::swap(p[i], p[i + tmp]);
  for (int i = x; i < x + len; i += len / 3) { solve(i, len / 3); }
}

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#else
  freopen("dance.in", "r", stdin);
  freopen("dance.out", "w", stdout);
#endif
#endif

  scanf("%d", &n);
  scanf("%s", opt);
  len = strlen(opt);
  int tmp = pow(3, n);
  for (int i = 0; i < tmp; ++i) { p[i] = i; }
  for (int i = 0; i < len; ++i) {
    if (opt[i] == 'S') {
      solve(0, tmp);
    } else {
      --shf;
    }
  }
  shf %= tmp;
  shf += tmp;
  shf %= tmp;
  for (int i = shf, cnt = 0; cnt < tmp; ++cnt, i = (i + 1) % tmp) {
    printf("%d ", p[i]);
  }
  return 0;
}